package com.student.Activitys.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.student.Activitys.R;
import com.student.Activitys.adapter.base.BaseRecyleViewAdapter;
import com.student.Activitys.adapter.viewholder.DefaultViewHolder;
import com.student.Activitys.bean.ScheduleWeekBean;

import java.util.List;

/**
 * 项目名称：智慧校园学生端
 * 类描述：阶段性评价 查看 （期中、期末） adapter
 * 创建人：张飞祥
 * 创建时间：2017/10/17 9:15
 * 修改人：张飞祥
 * 修改时间：2017/10/17 9:15
 * 修改备注：
 */
public class StageSeeAdapter extends BaseRecyleViewAdapter {


    private Context context;
    private List<ScheduleWeekBean> list;

    public StageSeeAdapter(Context context, List<ScheduleWeekBean> list) {
        super(context, list);
        this.context = context;
        this.list = list;
    }

    @Override
    protected int getLayoutItmeResId() {
        return R.layout.item_default;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof DefaultViewHolder) {
            DefaultViewHolder viewHolder = (DefaultViewHolder) holder;
            //将数据保存在itemView的Tag中，以便点击时进行获取
            viewHolder.itemView.setTag(position);
            //设置课程名
            viewHolder.tvDefaultName.setText(list.get(position).getKCM());
            //判断是否评价
            if(list.get(position).getSFPJ().equals("1")) {
                viewHolder.labelDefault.setText("已评价");                      //已经评价
                viewHolder.labelDefault.setBgColor(Color.rgb(255,182,127));
            }else{
                viewHolder.labelDefault.setText("待评价");                      //没有请假、评价
                viewHolder.labelDefault.setBgColor(Color.rgb(204,204,204));
            }
        }
    }

    @Override
    public RecyclerView.ViewHolder getViewHolder(View view) {
        return new DefaultViewHolder(view);
    }
}
